﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MagicArena.framework.physics;
using MagicArena.framework.toon;
using MagicArena.framework.state;
using MagicArena.framework.physics._2d;

namespace MagicArena.framework.component
{
    public class VisionController2dCircle : AVisionController
    {
        private ACollider _Collider;

        public VisionController2dCircle(Toon t, float radius) : base(new State(State.Common.Radius, radius))
        {
            State x = State.FindById(t.States, State.Common.Xpos);
            State y = State.FindById(t.States, State.Common.Ypos);
            
            _Collider = new Collider2dCircle(x, y, base.Radius);

            _Collider.Collision += OnCollisionHandler;
        }
        public ~VisionController2dCircle()
        {
            _Collider.Collision -= OnCollisionHandler;
        }

        public override void Update(Microsoft.Xna.Framework.GameTime gameTime)
        {
            //TODO Does anything need done here?
        }

        private void OnCollisionHandler(object sender, MagicArena.framework.physics.ACollider.CollisionEventArgs e)
        {
            ACollider other = e.Other;
            if (other.HasToon)
            {
                //TODO Add toon to  vision 
            }
        }
    }
}
